package org.example.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.pojo.CategoryArticleCountDTO;
import org.example.pojo.ClientAdCountDTO;

import java.util.List;

@Mapper
public interface StatisticsMapper {

    @Select("SELECT c.name AS clientName, COUNT(ap.id) AS adCount " +
            "FROM client c " +
            "LEFT JOIN ad_position ap ON c.id = ap.client_id " +
            "WHERE c.create_user = #{id} " +  // 添加管理员ID过滤
            "GROUP BY c.id")
    List<ClientAdCountDTO> getClientAdCounts(Integer id);

    @Select("SELECT c.category_name AS categoryName, COUNT(at.id) AS articleCount " +
            "FROM category c " +
            "LEFT JOIN article at ON c.id = at.category_id " +
            "WHERE c.create_user = #{id} " +  // 添加管理员ID过滤
            "GROUP BY c.id")
    List<CategoryArticleCountDTO> categoryArticleDTOs(Integer id);
}
